package com.authine.cloudpivot.common;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author carter
 * create_date  2020/7/8 11:19
 * description     错误测试接口
 */
@Api(tags = "公共服务::常见错误演示")
@RestController
@Slf4j
public class ErrorCodeControllerI {

    @ApiOperation("校验异常")
    @GetMapping("/error/check_param")
    public void checkParamException() {
        Assert.isTrue(1 == 2, "xxx参数校验错误");
    }

    @ApiOperation("缺少参数异常")
    @GetMapping("/error/miss_param")
    public void missParamException(@RequestParam("name") String name) {

        log.info("缺少参数异常,name:{}", name);

    }

    @ApiOperation("格式异常")
    @GetMapping("/error/format_param")
    public void formatParamException() {

        throw new org.springframework.http.converter.HttpMessageNotReadableException("");

    }

    @ApiOperation("业务异常")
    @GetMapping("/error/biz")
    public void bizException() {
    }

    @ApiOperation("系统异常")
    @GetMapping("/error/sys")
    public void sysException() {
        String a = null;
        a.getBytes();
    }


}
